Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Add server side pagination #1673

Merged
merged 2 commits into from
Jan 2, 2023
Merged

Add server side pagination #1673

merged 2 commits into from
Jan 2, 2023

Conversation

JSReds
Copy link
Contributor

@JSReds JSReds commented Nov 15, 2022

Connects-to: #
See:
Depends-on:
Change-type: major|minor|patch


Contributor checklist
  • I have regenerated jest snapshots for any affected components with npm run generate-snapshots
Reviewer Guidelines
  • When submitting a review, please pick:
    • 'Approve' if this change would be acceptable in the codebase (even if there are minor or cosmetic tweaks that could be improved).
    • 'Request Changes' if this change would not be acceptable in our codebase (e.g. bugs, changes that will make development harder in future, security/performance issues, etc).
    • 'Comment' if you don't feel you have enough information to decide either way (e.g. if you have major questions, or you don't understand the context of the change sufficiently to fully review yourself, but want to make a comment)

@JSReds JSReds self-assigned this Nov 15, 2022
@JSReds JSReds force-pushed the add-server-side-pagination branch 2 times, most recently from 2df257f to 222d7f6 Compare November 24, 2022 16:16
@JSReds JSReds force-pushed the add-server-side-pagination branch 2 times, most recently from 30b39b4 to fbea07a Compare December 9, 2022 13:45
@JSReds JSReds marked this pull request as ready for review December 9, 2022 13:45
@JSReds JSReds requested a review from thgreasi December 9, 2022 13:45
Copy link
Contributor

@thgreasi thgreasi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is GREAT!!!

@@ -186,10 +193,12 @@ export class TableBase<T extends {}> extends React.Component<
this.setRowSelection(checkedItems);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also need to doublecheck how selection works.

  • We need to update toggleChecked, since it does include a client side sorting and assumes it has all the data while trying to map the checkbox the user clicked and the item that the row was about.
  • We probably also need to check toggleAllChecked as well, and maybe in server side more it should be returning all, to let the consumer know that they need to query and fetch AAAAAALLLLLLLLLL item IDs from the backend.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Work in progress. I need to merge this PR first to be able to do something like this in the following PR:

isDisabled & actionFn:

  • isServerSide: false => T[]
  • isServerSide: true =>
  • selecting N items: { id: { $in: [] } }
  • select-all: { $and: [{ belongs_to__application: xyz }, searchFilters] }

@JSReds JSReds force-pushed the add-server-side-pagination branch 2 times, most recently from 422d9d0 to b307ce4 Compare December 29, 2022 15:52
@JSReds JSReds requested a review from thgreasi December 29, 2022 15:52
const totalItems = items.length;
const _itemsPerPage = itemsPerPage || 50;
const totalItems = serverSide ? pagination?.totalItems : items.length;
const itemsPerPage = pagination?.itemsPerPage || DEFAULT_ITEMS_PER_PAGE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this is a minor & itemsPerPage is still in the properties, we should

Suggested change
const itemsPerPage = pagination?.itemsPerPage || DEFAULT_ITEMS_PER_PAGE;
const itemsPerPage = pagination?.itemsPerPage ?? this.props.itemsPerPage ?? DEFAULT_ITEMS_PER_PAGE;

both here and in setPage.
Otherwise we can do a major and remove it completely.
I think atm I'm in favor of the minor so that we can do a single major after the product call on how selection should work.

Change-type: minor
Signed-off-by: Andrea Rosci <[email protected]>
@JSReds JSReds force-pushed the add-server-side-pagination branch from b307ce4 to 667f21a Compare January 2, 2023 11:17
Change-type: patch
Signed-off-by: Andrea Rosci <[email protected]>
@JSReds JSReds force-pushed the add-server-side-pagination branch from 667f21a to f169c31 Compare January 2, 2023 11:18
@thgreasi thgreasi merged commit 1a12778 into master Jan 2, 2023
@thgreasi thgreasi deleted the add-server-side-pagination branch January 2, 2023 11:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants